﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TMS_Master.DTO.Personnel;
using TMS_Master.Personnel_module;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;

namespace TMS_Master
{
    public class PersonnelService : CrudAppService
        <Personnel,
        PersonnelDTO,
        Guid,
        PagedAndSortedResultRequestDto,
        PersonnelDTOText>,
        IPersonnelService
    {
        public readonly IRepository<Personnel, Guid> tMSApp;
        public PersonnelService(IRepository<Personnel, Guid> _tMSApp) : base(_tMSApp)
        {
            tMSApp = _tMSApp;
        }
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="Staff"></param>
        /// <returns></returns>
        public async Task<int> AddPersonnel(PersonnelDTO Personnel)
        {
            Personnel Add = ObjectMapper.Map<PersonnelDTO, Personnel>(Personnel);
            await tMSApp.InsertAsync(Add);
            return 1;
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public async Task DelPersonnel(Guid Id)
        {
            await tMSApp.DeleteAsync(Id);
        }
        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public async Task<PersonnelDTO> FanPersonnel(Guid Id)
        {
            Personnel b = await tMSApp.GetAsync(Id);
            PersonnelDTO fan = ObjectMapper.Map<Personnel, PersonnelDTO>(b);
            return fan;
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <returns></returns>
        public async Task<List<PersonnelDTO>> GetPersonnel()
        {
            List<Personnel> p = await tMSApp.ToListAsync();
            List<Personnel> Personnel = p;
            List<PersonnelDTO> PersonnelDTOs = ObjectMapper.Map<List<Personnel>, List<PersonnelDTO>>(Personnel);
            return PersonnelDTOs;

        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="become"></param>
        /// <returns></returns>
        public async Task<int> UptPersonnel(PersonnelDTO quit)
        {
            Personnel e = await tMSApp.GetAsync(quit.Id);
            return 1;
        }
    }
}
